\subsection{Rebuilding Packages from Source}  \label{appendix:rpmbuild}

Users of OpenHPC may find it desirable to rebuild one of the supplied packages
to apply build customizations or satisfy local requirements. One way to
accomplish this is to install the appropriate source RPM, modify the specfile
as needed, and rebuild to obtain an updated binary RPM. A brief example using
the FFTW library is highlighted below.  Note that the source RPMs can be downloaded from the
community build server at \href{https://build.openhpc.community}
{\color{blue}{https://build.openhpc.community}} via a web browser or directly
via \texttt{rpm} as highlighted below. The OpenHPC build system design
leverages several keywords to control the choice of compiler and MPI families
for relevant development libraries and the \texttt{rpmbuild} example
illustrates how to override the default mpi\_family.

\begin{lstlisting}[language=bash,keywords={},basicstyle=\fontencoding{T1}\footnotesize\ttfamily,
    literate={VER}{\OHPCVerTree{}}1 {OSREPO}{\OSRepo{}}1 {-}{-}1]
# Install rpm-build package from base OS distro
[test@sms ~]$ (*\install*) rpm-build

# Download SRPM from OpenHPC repository and install locally
[test@sms ~]$ rpm -i \
  http://build.openhpc.community/OpenHPC:/VER/OSREPO/src/fftw-gnu-openmpi-ohpc-3.3.4-4.1.src.rpm

# Modify spec file as desired
[test@sms ~]$ cd ~/rpmbuild/SPECS
[test@sms ~rpmbuild/SPECS]$ perl -pi -e "s/enable-static=no/enable-static=yes/" fftw.spec

# Increment RPM release so package manager will see an update
[test@sms ~rpmbuild/SPECS]$ perl -pi -e "s/Release:   4.1/Release:   5.1/" fftw.spec

# Rebuild binary RPM. Note that additional directives can be specified to modify build
[test@sms ~rpmbuild/SPECS]$ rpmbuild -bb --define "mpi_family mvapich2" fftw.spec

# As privileged user, install the new package
[sms](*\#*) (*\install*) ~test/rpmbuild/RPMS/x86_64/fftw-gnu-mvapich2-ohpc-3.3.4-5.1.rpm
\end{lstlisting}
